<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	session.setAttribute("basePath", basePath);
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
	<button id="test">测试按钮</button>
	<div style="border: 1px solid red;" id="content"></div>
	<div style="border: 1px solid yellow;" id="json_div"></div>
	<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
	<script type="text/javascript" src="js/json2.js"></script>
	<script type="text/javascript">
		$(function()
		{
			$("#test").click(function()
			{
				var data_json =
				{
					"orderid" : "10001",
					"user" :
					{
						"userid" : "10001",
						"receivername" : "甘先生",
						"receiverphone" : "15688888888",
						"province" : "广东省",
						"city" : "广州市",
						"area" : "天河区",
						"receiveraddress" : "广东省广州市天河区xx路x号",
						"idcardname" : "甘先生",
						"idcardnumber" : "411524000000000000"
					},
					"goods" : [
					{
						"goodsid" : "1831",
						"stockid" : "2924",
						"count" : "1"
					} ]
				};

				$("#json_div").html(JSON.stringify(data_json));

				$.ajax(
				{
					url : "http://api.soeasyo2o.com:8080/order/create?appid=20001&timestamp=1442563484&sign=09eddade46a6908760756562456b0594",
					type : "POST",
					dataType : "json",
					beforeSend : function(XMLHttpRequest)
					{
						$("#test").attr("disabled", "disabled");
						$("#test").html("正在提交请求中...");
					},
					data : data_json,
					success : function(json, textStatus)
					{
						$("#content").html(json);
					},
					error : function(xhr, textStatus, errorThrown)
					{
						alert("提交失败，请仔细检查您的输入是否满足要求。" + xhr.readyState + "," + xhr.status + "," + textStatus + "," + errorThrown);
					},
					complete : function(XMLHttpRequest, textStatus)
					{
						$("#test").removeAttr("disabled");
						$("#test").html(test_html);
					}
				});

				$.ajax(
				{
					url : "http://api.soeasyo2o.com:8080/order/create?appid=20001&timestamp=1442563484&sign=09eddade46a6908760756562456b0594",
					type : "POST",
					dataType : "json",
					traditional : true,
					beforeSend : function(XMLHttpRequest)
					{
						$("#test").attr("disabled", "disabled");
						$("#test").html("正在提交评论信息中...");
					},
					data : data_json,
					success : function(json, textStatus)
					{
						$("#content").html(json);
					},
					error : function(XMLHttpRequest, textStatus, errorThrown)
					{
						alert("提交失败，请仔细检查您的输入是否满足要求。" + xhr.readyState + "," + xhr.status + "," + textStatus + "," + errorThrown);
					},
					complete : function(XMLHttpRequest, textStatus)
					{
						$("#test").removeAttr("disabled");
						$("#test").html(test_html);
					}
				});
			});
		});
	</script>
</body>
</html>